home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Communications / General / LineShare Folder / Put Onto Productions Disks / LineShare Scripts / Rockwell Fax1&Data < prev    next >
Text File  |  1994-03-21  |  7KB  |  332 lines

  1. ! Version 2.1
  2. !
  3. !$ Use this script with Rockwell-based (Supra, Xeba, Zoom, etc) 14400bps fax modems.
  4. !$ Supports: fax and generic data incoming calls.
  5.  
  6. !$ Make sure that *Class 1* fax software is installed, and that your
  7. !$ modem HAS THE NEW ROMs supporting adaptive answering.
  8. !
  9. !$ A cable for hardware handshaking is required
  10.  
  11. ^2 Speaker On:        = Enum("Never" = "0","During Connect" = "1", "Always"="2") "1"
  12. ^3 Speaker Volume:       = Enum("Low"="1","Medium"="2","High"="3") "2"
  13. ^4 Answer On:         = Enum("1 Ring"="1","2 Rings"="2","3 Rings"="3","5 Rings"="5","7 Rings"="7") "2"
  14. ^5 Result codes:   = Enum("DTE rate"="0","DCE rate"="1","DTE rate & ARQ"="08","DCE rate & ARQ"="09") "0"
  15. ^6 Handshake wires:   = Bool("Both"="&D0\K0","CTS only"="&D2\K5") "&D2\K5"
  16.  
  17. ! ------------------------------------------
  18. ! Resetting the modem:
  19. ! ------------------------------------------
  20. @Hangup
  21.   SetTries 2
  22.   Flush
  23.   HsReset 0,0,17,19,0,0
  24. !
  25. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  26. ! to enter the command mode
  27. !
  28. @Label 1
  29.   matchclr
  30.   matchstr 1 2 "OK\r\n"
  31.   write "ATH0&F\r"
  32.   matchread 20
  33.   ChrDelay 1
  34.   Write "+++"
  35.   ChrDelay 0
  36.   DtrClear
  37.   LBreak
  38.   DtrSet
  39. !
  40.   DecTries
  41.   IfTries 1 1
  42.   SerReset 19200,0,8,1
  43.   IfTries 0 1
  44. !
  45. ! OSErr -6019 "Modem error - the modem is not responding"
  46. !
  47.   exit -6019
  48. @Label 2
  49.   write "AT+FCLASS=0\r"
  50.   Jsr 100
  51.   write "AT+FAE=0\r"
  52.   Jsr 100
  53.   exit 0
  54.  
  55. ! ------------------------------------------
  56. !    Receiving incoming calls
  57. ! ------------------------------------------
  58. @ANSWER
  59. !
  60. ! Set the modem preferred speed first
  61. !
  62.   SerReset 19200,0,8,1
  63.   Jsr 80
  64.  
  65. @Label 10
  66. !
  67. ! Set the common options
  68.   Jsr 70
  69. !
  70. ! Set the communication options:
  71. ! • \N3 &Q5: Auto-reliable
  72. ! • &K3: HW flow control       (for ARA, Fax should not use a handshake on receiving)
  73. !
  74.   Write "AT\\N3&Q5&K3WS95=^5\r"
  75.   Jsr 100
  76. !
  77. ! Set Fax mode
  78. !
  79.   Write "AT+FCLASS=1\r"
  80.   Jsr 100
  81.   Write "AT+FAE=1\r"
  82.   Jsr 100
  83. !
  84. ! It's for Rockwell ONLY! Set FCLASS to 0 again - otherwise,
  85. ! it cannot accept data calls
  86. !
  87.   Write "AT+FCLASS=0\r"
  88.   Jsr 100
  89. !
  90. ! Tell the modem to determine the type of the incoming call
  91. ! Fetch the tube after ^4 rings
  92. !
  93.   Write "ATS0=^4V0\r"
  94.   Jsr 110
  95. !
  96. ! Everything is ready - let's sit and wait for a call
  97. ! We'll wait for 2 minutes, then reinitiate the modem
  98. !
  99.  SetVar A ""
  100.   Note "Waiting for a fax or data call…"
  101.   MatchClr
  102.  
  103.   Matchstr 02 40 "10\r"
  104.   MatchStr 03 41 "11\r"
  105.   MatchStr 04 42 "13\r"
  106.   MatchStr 05 43 "12\r"
  107.   MatchStr 06 44 "14\r"
  108.   MatchStr 07 45 "15\r"
  109.   MatchStr 08 46 "16\r"
  110.  
  111.   MatchStr 13 19 "80\r"
  112.   MatchStr 14 19 "77\r"
  113.  
  114.   MatchStr 15 31 "33\r"
  115.   Matchstr 16 30 "1\r"
  116.  
  117.   Matchstr 17 18 "2\r"
  118.   Matchstr 18 17 "3\r"
  119.   Matchstr 19 17 "8\r"
  120.   Matchstr 20 17 "7\r"
  121. @Label 16
  122.   Matchread 1200
  123. @Label 17
  124.   Note "Tuning again…"
  125.   Jump 10
  126.  
  127. @Label 18
  128.   Note "Ring…"
  129.   Jump 16
  130.  
  131. @Label 19
  132.   Note "Error correction on"
  133. !  ifStr 5 16 "0"
  134.   SetVar A "/ARQ"
  135.   Jump 16
  136.  
  137. !
  138. ! Data connection has been established (we read "CARRIER")
  139. ! Put the "CONNECT" back to the buffer and attach the "Data" subPort
  140. ! if it was an incoming call, put the "RING" before the "CONNECT"
  141. !
  142. @Label 20
  143.   QueueInput "\r\nCONNECT "
  144.   Jump 28
  145. @Label 21
  146.   QueueInput "\r\nCARRIER "
  147. @Label 28
  148.   ifOriginate 29
  149.   QueueInput "\r\nRING\r\n"
  150. @Label 29
  151.   Attach "Data" (DTR,Escape)
  152. !
  153. ! Fax connection has been established (we read "FAX")
  154. ! Put the +FCON back to the buffer,
  155. ! if it was an incoming call, put the "RING" before the "+FCON"
  156. ! Attach the "Fax" subPort
  157. !
  158. @Label 30
  159.   QueueInput "1\r"
  160.   ifOriginate 32
  161. @Label 31
  162.   QueueInput "2\r2\r"
  163. @Label 32
  164.   Attach "Fax" (Reset(2400),IdleLimit=30)
  165.  
  166. !
  167. ! Converting numeric responses into the verbal
  168. !
  169. @Label 40
  170.   QueueInput "2400^A\r\n"
  171.   Jump 20
  172. @Label 41
  173.   QueueInput "4800^A\r\n"
  174.   Jump 20
  175. @Label 42
  176.   QueueInput "7200^A\r\n"
  177.   Jump 20
  178. @Label 43
  179.   QueueInput "9600^A\r\n"
  180.   Jump 20
  181. @Label 44
  182.   QueueInput "12000^A\r\n"
  183.   Jump 20
  184. @Label 45
  185.   QueueInput "14400^A\r\n"
  186.   Jump 20
  187. @Label 46
  188.   QueueInput "19200^A\r\n"
  189.   Jump 20
  190.  
  191. ! ------------------------------------------
  192. ! Originating a call through the "Data" subport
  193. ! ------------------------------------------
  194. @ORIGINATE "Data"
  195.   SerReset 19200,0,8,1
  196.   Jsr 80
  197. !
  198. ! Set the common options
  199. !
  200.   Jsr 70
  201. ! Set the app's settings (except Vx and Qx)
  202.   EmitClear "V","Q"
  203.   Jsr 60
  204.   SetSpeed *
  205.   Jsr 80
  206. !
  207. ! Prepare to receive all error result codes, dial the number
  208. !
  209.   Jsr 90
  210.   MatchStr 1 20 "\r\nCONNECT "
  211.   MatchStr 2 21 "\r\nCARRIER "
  212.   MatchRead 1000
  213.   Write "\r"
  214.   Exit -6019
  215.  
  216. ! ------------------------------------------
  217. ! Originating a call through the "Fax" subPort
  218. ! ------------------------------------------
  219. @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
  220. !
  221. ! Set the "Fax" speed
  222. !
  223.   SerReset 19200,0,8,1
  224.   Jsr 80
  225. !
  226. ! Set the common options
  227. !
  228.   Jsr 70
  229. !
  230. ! Set the Fax mode
  231. ! &K4: Xon/Xoff handshake
  232. ! &S0: DSR always on (see above)
  233. !
  234.   Write "AT&S0&K4+FCLASS=1\r"
  235.   Jsr 100
  236. !
  237. ! Now emit all commands that the application has sent to that port,
  238. ! except "FCLASS", etc
  239. !
  240.   EmitClear "FCLASS","V","X","E"
  241.   Jsr 60
  242.   Write "ATV0\r"
  243.   Jsr 110
  244. !
  245. ! Prepare to receive all error result codes, dial the number
  246. !
  247.   MatchClr
  248.   MatchStr 01 30 "1\r"
  249.   MatchStr 13 93 "3\r"
  250.   MatchStr 14 94 "8\r"
  251.   MatchStr 15 92 "7\r"
  252.   Write "ATD^1\r"
  253.   HsReset *
  254.   MatchRead 900
  255.   Write "\r"
  256.   Exit -6019
  257. !
  258. ! This section emits all modem commands sent from the client application
  259. ! For each set of commands the "OK" answer is awaited
  260. !
  261. @Label 60
  262.   EmitStart
  263. @Label 61
  264.   EmitCommand 62
  265.   Jsr 100
  266.   Jump 61
  267. @Label 62
  268.   return
  269. !
  270. ! This section initiates the modem before ANSWER and ORIGINATEs:
  271. ! extended responses + connect at the highest rate + speaker control +
  272. ! reset on Dtr drop + DCD valid
  273. ! Verbal responses mode, no echo 
  274. !
  275. @Label 70
  276.   Write "ATX4N1M^2L^3^6&C1V1E0\r"
  277.   Jsr 100
  278.   return 
  279.  
  280. !
  281. ! This section syncronize the modem after the serial port speed switching
  282. !
  283. @Label 80
  284.   ChrDelay 1
  285.   Write "AT\r"
  286.   ChrDelay 0
  287.   Jsr 100
  288.   return
  289. !
  290. ! Prepare to receive error result codes, send the dialing command and
  291. ! set the user's handshake mode
  292. !
  293. @Label 90
  294.   MatchClr
  295.   MatchStr 12 91 "NO DIALTONE\r\n"
  296.   MatchStr 13 92 "BUSY\r\n"
  297.   MatchStr 14 93 "NO CARRIER\r\n"
  298.   MatchStr 15 94 "NO ANSWER\r\n"
  299.   Write "ATD^1\r"
  300.   HsReset *
  301.   return
  302. @Label 91
  303.   exit -6020
  304. @Label 92
  305.   exit -6022
  306. @Label 93
  307.   exit -6021
  308. @Label 94
  309.   exit -6023
  310. !
  311. ! Processing the AT command:
  312. ! OK -> proceed
  313. ! ERROR or TimeOut ->exit -6019
  314. ! It can be called AFTER the "Write" command, since LineShare buffers input
  315. !
  316. @Label 100
  317.   MatchClr
  318.   MatchStr 1 103 "\r\nOK\r\n"
  319.   MatchStr 2 102 "\r\nERROR\r\n"
  320. @Label 101
  321.   MatchRead 20
  322. @Label 102
  323.   Exit -6019
  324. @Label 103
  325.   return
  326.  
  327. @Label 110
  328.   MatchClr
  329.   MatchStr 1 103 "0\r"
  330.   MatchStr 2 102 "4\r"
  331.   Jump 101
  332.